In many video encoding methods, the amount of generated code varies depending on the character of an input image. Therefore, an encoding bit rate control technique is required for controlling the amount of generated code and keeping a constant encoding bit rate.
The amount of generated code closely relates to the quantization step size, and the amount of generated code is controlled by varying the quantization step size.
In test model 5 (abbreviated as “TM5”) of MPEG-2, code amount control is performed using a relationship between the quantization step size and the amount of generated code (see, for example, Non-Patent Document 1).
Below, the code amount control in TM5 of MPEG-2 will be explained.
In TM5 of MPEG-2, code amount control is performed using a unit called GOP (group of pictures), which may include I, P, and B pictures having different picture types such as I, P, and B picture types.
FIG. 7 shows a flowchart of the code amount control in TM5 of MPEG-2.
As shown in the flowchart, in the code amount control of TM5 in MPEG-2, in the first step S301, a complex index Xx for each picture type (x=i, p, b (which respectively correspond to I, P, and B pictures)) is computed by the following formula:Xx=Sx·<Qx>
In the above formula, x indicates the picture type, Sx indicates the amount of code generated for an image which has the same picture type as the present image and was encoded most recently, and <Qx> indicates an average of the quantization step size in the relevant encoding.
Generally, the code amount Sx is in inverse proportion to the quantization step size Qx. Therefore, computation of the complex index Xx gives a relationship between the amount of generated code and the quantization step size.
In the next step S302, a target amount Tx of code (x=i, p, b) for each picture type is computed by the following formulas.
                                          T            i                    =                      R                          1              +                                                                    N                    p                                    ⁢                                      X                    p                                                                                        X                    i                                    ⁢                                      K                    p                                                              +                                                                    N                    b                                    ⁢                                      X                    b                                                                                        X                    i                                    ⁢                                      K                    b                                                                                      ⁢                                  ⁢                              T            p                    =                      R                                          N                p                            +                                                                    N                    b                                    ⁢                                      K                    p                                    ⁢                                      X                    b                                                                                        X                    p                                    ⁢                                      K                    b                                                                                      ⁢                                  ⁢                              T            b                    =                      R                                          N                b                            +                                                                    N                    p                                    ⁢                                      K                    b                                    ⁢                                      X                    p                                                                                        X                    b                                    ⁢                                      K                    p                                                                                                          [                  Formula          ⁢                                          ⁢          1                ]            
Here, R indicates the amount of code allocated to the relevant GOP, Np indicates the number of P pictures in the GOP, Nb indicates the number of B pictures in the GOP, and Kp and Kb are constants.
The above formulas show that in order to set the target code amount Ti, P pictures are converted to I pictures in accordance with Xp/Xi, B pictures are converted to I pictures in accordance with Xb/Xi, and the target code amount Ti is computed based on the converted values, the numbers Np and Nb of pictures, and the amount R of code allocated to the GOP.
In order to set the target code amount Tp, B pictures are converted to P pictures in accordance with Xb/Xp, and the target code amount Tp is computed based on the converted value, the numbers Np and Nb of pictures, and the amount R of code allocated to the GOP.
In order to set the target code amount Tb, P pictures are converted to B pictures in accordance with Xp/Xb, and the target code amount Tb is computed based on the converted value, the numbers Np and Nb of pictures, and the amount R of code allocated to the GOP.
In the next step S303, based on the target code amount Tx set above for the pictures, the quantization step size for a small block as an encoding target is determined.
In the next step S304, each small block is subjected to quantization and encoding by using the determined quantization step size.
In the next step S305, after encoding of one picture is completed, an average <Qx> of the quantization step size is computed.
In the next step S306, (after encoding of one picture is completed,) the actual amount Sx of generated code is measured.
Based on the measured amount Sx of generated code and the computed average quantization step size <Qx>, in step S301 again, the complex index XX for each picture type is updated.
In accordance with the above method, in TM5 of MPEG-2, a target amount of code is assigned to each picture when encoding the picture, thereby controlling the amount of generated code.
In the conventional method, the target amount of code is determined based on the amount of code allocated to the relevant GOP and the complex index for each picture type. This method is based on a prior relationship such that the quantization step size is inversely proportional to the amount of generated code.
However, if the amount of code generated for an element (e.g., the motion vector for motion-compensated prediction, the encoding mode, etc.) which has no relation to the quantization step size is dominant, then the prior relationship may be ineffective. If the prior relationship is ineffective, the amount of generated code is erroneously estimated, and thus the target amount of code is not accurately determined.
In order to solve the above problem, Patent Document 1 discloses a method of performing quantization control without considering the amount of fixed-length code.
In this method, the amount of code required for each element (e.g., DC components or motion vectors in the intraframe encoding mode of MPEG-2) which does not depend on the bit rate is defined as the amount of code independent of the quantization step size.    Non-Patent Document 1: MPEG-2, Test Model5(TM5), Doc.ISO/IECJTC1/SC29/WG11/NO400, Test Model Editing Committee, pp. 59-63, April, 1993.    Patent Document 1: Japanese Unexamined Patent Application, First Publication No. H10-290461.